/**
 * 初始化部门详情对话框
 */
var CustomerInfoDlg = {
    CustomerInfoData: {},
    zTreeInstance: null,
    validateFields: {
        customerName: {
            validators: {
                notEmpty: {
                    message: '客户姓名不能为空'
                },
                stringLength: {
                    /*长度提示*/
                    max: 25,
                    message: '客户姓名长度不能超过25，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        identificationNumber: {
            validators: {
                notEmpty: {
                    message: '标识号不能为空'
                },
                stringLength: {
                    /*长度提示*/
                    max: 25,
                    message: '标识号长度不能超过25，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        pseudonym: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 25,
                    message: '化名长度不能超过25，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        referee: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 25,
                    message: '推荐人长度不能超过25，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        idCardNo: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 25,
                    message: '身份证号长度不能超过25，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        fixedTelephone: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 25,
                    message: '座机电话长度不能超过25，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        email: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 60,
                    message: '座机电话长度不能超过60，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        zipCode: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 40,
                    message: '座机电话长度不能超过40，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        finalAuditor: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 25,
                    message: '审核人长度不能超过25，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        qqNumber: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 25,
                    message: 'qq号长度不能超过25，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        wechatNumber: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 45,
                    message: '微信号长度不能超过45，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        otherContact: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 100,
                    message: '其他联系方式长度不能超过100，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        address: {
            validators: {
                stringLength: {
                    /*长度提示*/
                    max: 100,
                    message: '地址长度不能超过100，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        archiving: {
            validators: {
                notEmpty: {
                    message: '建档人不能为空'
                },
                stringLength: {
                    /*长度提示*/
                    max: 20,
                    message: '建档人长度不能超过20，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        customerPhone: {
            validators: {
                notEmpty: {
                    message: '电话不能为空'
                },
                regexp: {
                    /* 只需加此键值对，包含正则表达式，和提示 */
                    regexp: /^\d{5,13}$/,
                    message: '电话为5到13位的数字，请重新输入...'
                },
                stringLength: {
                    /*长度提示*/
                    max: 20,
                    message: '电话长度不能超过20，请重新输入...'
                }/*最后一个没有逗号*/
            }
        },
        // customerPhone: {
        //     validators: {
        //         notEmpty: {
        //             message: '电话不能为空'
        //         },
        //         stringLength: {
        //             /*长度提示*/
        //             max: 11,
        //             message: '请重新输入正确的手机号...'
        //         },/*最后一个没有逗号*/
        //         regexp: {
        //             /* 只需加此键值对，包含正则表达式，和提示 */
        //             regexp: /^[0-9]*$/,
        //             message: '请重新输入正确的手机号...'
        //         },
        //     }
        // },
        customerAge: {
            validators: {
                regexp: {
                    /* 只需加此键值对，包含正则表达式，和提示 */
                    regexp: /^([0-9]\d{0,2}|1000)$/,
                    message: '年龄为 0 ~ 1000 间整数，请重新输入...'
                },
            }
        }
    }
};

/**
 * 清除数据
 */
CustomerInfoDlg.clearData = function () {
    this.customerInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
CustomerInfoDlg.set = function (key, val) {
    this.customerInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
CustomerInfoDlg.get = function (key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
CustomerInfoDlg.close = function () {
    // parent.layer.close(window.parent.Customer.layerIndex);
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    parent.layer.close(index);
}


/**
 * 显示部门选择的树
 *
 * @returns
 */
CustomerInfoDlg.showCustomerSelectTree = function () {
    var pName = $("#pName");
    var pNameOffset = $("#pName").offset();
    $("#parentCustomerMenu").css({
        left: pNameOffset.left + "px",
        top: pNameOffset.top + pName.outerHeight() + "px"
    }).slideDown("fast");

    $("body").bind("mousedown", onBodyDown);
}

/**
 * 隐藏部门选择的树
 */
CustomerInfoDlg.hideCustomerSelectTree = function () {
    $("#parentCustomerMenu").fadeOut("fast");
    $("body").unbind("mousedown", onBodyDown);// mousedown当鼠标按下就可以触发，不用弹起
}

/**
 * 收集数据
 */
CustomerInfoDlg.collectData = function () {
    this.set('id').set('customerName').set('pseudonym').set('customerPhone').set('customerSex').set('customerAge')
        .set('birthday').set('customerStatus').set('xcustomerStatus').set('referee').set('refereeShip').set('idCardNo').set('fixedTelephone')
        .set('qqNumber').set('wechatNumber').set('isHaveChildren').set('isReturnVisit').set('email').set('zipCode').set('identificationNumber')
        .set('numberOfAudits').set('finalAuditor').set('auditorTime').set('consumAbility').set('nonTransactionLevel').set('appointmentPayService')
        .set('transactionLevel').set('characters').set('consumptionHabits').set('otherContact').set('country').set('address')
        .set('province').set('cities').set('region').set('maritalStatus').set('occupation').set('filingTime').set('medicalRecordNumber')
        .set('arrivalTime').set('fieldTc').set('causeOfNoReturnVisit').set('entryClerk').set('recordPeople').set('reservationsId')
        .set('oneChannel').set('twoChannel').set('thrChannel').set('oneMedium').set('twoMedium').set('thrMedium').set('department')
        .set('archiving').set('toVoidremarks').set('remarks').set('actualAccountBalance').set('giveAccountBalance').set('refundMoney').set('phoneSharShip');
}


/**
 * 验证数据是否为空
 */
CustomerInfoDlg.validate = function () {
    $('#customerInfoForm').data("bootstrapValidator").resetForm();
    $('#customerInfoForm').bootstrapValidator('validate');
    return $("#customerInfoForm").data('bootstrapValidator').isValid();
}

CustomerInfoDlg.getReferee = function () {
    var index = layer.open({
        type: 2,
        title: '添加推荐人',
        area: ['90%', '90%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/customer/to_referee'
    });
    this.layerIndex = index;
}

/**
 * 提交添加到店客户
 */
CustomerInfoDlg.addSubmit = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/add", function (data) {
        if (data == 1) {
            Feng.success("添加成功!");
            window.parent.parent.Customer.table.refresh();
            //window.parent.parent.$('#calendar').fullCalendar('refetchEvents');
            $('#cancel', parent.document).click();
        } else if (data == 0) {
            alert("客户今日已到过院");
        } else {
            alert("客户电话已存在");
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
    //提交后关闭所有弹出层
    //layer.closeAll();             //疯狂模式，关闭所有层
    // layer.closeAll('dialog');    //关闭信息框
    // layer.closeAll('page');      //关闭所有页面层
    // layer.closeAll('iframe');    //关闭所有的iframe层
    // layer.closeAll('loading');   //关闭加载层
    // layer.closeAll('tips');      //关闭所有的tips层
}

/**
 * 提交添加到店客户
 */
CustomerInfoDlg.addSubmitd = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/add", function (data) {
        if (data == 1) {
            Feng.success("添加成功!");
            window.parent.parent.$('#calendar').fullCalendar('refetchEvents');
            $('#cancel', parent.document).click();
        } else if (data == 0) {
            alert("客户今日已到过院");
        } else {
            alert("客户电话已存在");
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
    //提交后关闭所有弹出层
    //layer.closeAll();             //疯狂模式，关闭所有层
    // layer.closeAll('dialog');    //关闭信息框
    // layer.closeAll('page');      //关闭所有页面层
    // layer.closeAll('iframe');    //关闭所有的iframe层
    // layer.closeAll('loading');   //关闭加载层
    // layer.closeAll('tips');      //关闭所有的tips层
}

/**
 * 提交添加到店重咨客户
 */
CustomerInfoDlg.reconsulSubmit = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }
    var customerName = document.getElementById("customerName").value;
    var customerPhone = document.getElementById("customerPhone").value;
    var appointmentPayService = document.getElementById("appointmentPayService").value;
    var identificationNumber = document.getElementById("identificationNumber").value;
    if (customerName == null || customerName == "") {
        alert("请输入姓名！");
        return
    }
    if (customerPhone == null || customerPhone == "") {
        alert("请输入手机号！");
        return
    }
    if (appointmentPayService == null || appointmentPayService == "") {
        alert("请选择咨询项目！");
        return
    }
    if (identificationNumber == null || identificationNumber == "") {
        alert("请输入标识号！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/addReconsuling", function (data) {
        if (data == 1) {
            Feng.success("添加成功!");
            if (window.parent.parent.$('#wgz').val() == 1) {
                window.parent.parent.Customer.table.refresh();
                $('#cancel', parent.document).click();
            } else if (window.parent.parent.$('#wgz').val() == 2) {
                window.parent.parent.$('#calendar').fullCalendar('refetchEvents');
                $('#cancel', parent.document).click();
            }
        } else if (data == 0) {
            alert("客户今日已到过院");
        } else {
            alert("客户电话已存在");
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
}

/**
 * 提交添加到店重咨客户
 */
CustomerInfoDlg.reconsulSubmitd = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }

    var customerName = document.getElementById("customerName").value;
    var customerPhone = document.getElementById("customerPhone").value;
    var appointmentPayService = document.getElementById("appointmentPayService").value;
    var identificationNumber = document.getElementById("identificationNumber").value;
    if (customerName == null || customerName == "") {
        alert("请输入姓名！");
        return
    }
    if (customerPhone == null || customerPhone == "") {
        alert("请输入手机号！");
        return
    }
    if (appointmentPayService == null || appointmentPayService == "") {
        alert("请选择咨询项目！");
        return
    }
    if (identificationNumber == null || identificationNumber == "") {
        alert("请输入标识号！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/addReconsuling", function (data) {
        if (data == 1) {
            Feng.success("添加成功!");
            if (window.parent.parent.$('#wgz').val() == 1) {
                window.parent.parent.Customer.table.refresh();
                $('#cancel', parent.document).click();
            } else if (window.parent.parent.$('#wgz').val() == 2)
                window.parent.parent.$('#calendar').fullCalendar('refetchEvents');
            $('#cancel', parent.document).click();
        } else if (data == 0) {
            alert("客户今日已到过院");
        } else {
            alert("客户电话已存在");
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();

}

/**
 * 提交添加到店客户
 */
CustomerInfoDlg.addNatureCustomerSubmit = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }

    var customerName = document.getElementById("customerName").value;
    var customerPhone = document.getElementById("customerPhone").value;
    var appointmentPayService = document.getElementById("appointmentPayService").value;
    var identificationNumber = document.getElementById("identificationNumber").value;
    if (customerName == null || customerName == "") {
        alert("请输入姓名！");
        return
    }
    if (customerPhone == null || customerPhone == "") {
        alert("请输入手机号！");
        return
    }
    if (appointmentPayService == null || appointmentPayService == "") {
        alert("请选择咨询项目！");
        return
    }
    if (identificationNumber == null || identificationNumber == "") {
        alert("请输入标识号！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/addNatureCustomer", function (data) {
        var a = data.split(",");
        if (a[0] == 1) {
            Feng.success("添加成功!");
            if (window.parent.parent.$('#wgz').val() == 1) {
                window.parent.parent.Customer.table.refresh();
                $('#cancel', parent.document).click();
            } else if (window.parent.parent.$('#wgz').val() == 2) {
                window.parent.parent.$('#calendar').fullCalendar('refetchEvents');
                $('#cancel', parent.document).click();
            }
        } else {
            alert("客户电话已存在,请去进行匹配！");
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
}

/**
 * 提交添加到店客户
 */
CustomerInfoDlg.addNatureCustomerSubmitd = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }
    var customerName = document.getElementById("customerName").value;
    var customerPhone = document.getElementById("customerPhone").value;
    if (customerName == null || customerName == "") {
        alert("请输入姓名！");
        return
    }
    if (customerPhone == null || customerPhone == "") {
        alert("请输入手机号！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/addNatureCustomer", function (data) {
        var a = data.split(",");
        if (a[0] == 1) {
            Feng.success("添加成功!");
            window.parent.parent.$('#calendar').fullCalendar('refetchEvents');
            $('#cancel', parent.document).click();
        } else {
            alert("客户电话已存在,请去进行匹配！");
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
}

CustomerInfoDlg.toVoid = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var toVoidremarks = $('#toVoidremarks').val();
    if (toVoidremarks == null || toVoidremarks == "") {
        alert("请输入作废备注！");
        return
    }
    var ajax = new $ax(Feng.ctxPath + "/customer/toVoid", function (data) {
        Feng.success("操作成功!");
        window.parent.Customer.table.refresh();
        CustomerInfoDlg.close();
    }, function (data) {
        Feng.error("操作失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
CustomerInfoDlg.editSubmit = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var customerStatus = $('#customerStatus').val();
    if (customerStatus == "作废") {
        alert("此数据已作废");
        CustomerInfoDlg.close();
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/update", function (data) {
        if (data == 1) {
            Feng.success("修改成功!");
            window.parent.Customer.table.refresh();
            CustomerInfoDlg.close();
        } else {
            alert("客户电话已存在");
        }
    }, function (data) {
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
CustomerInfoDlg.editSubmits = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/update", function (data) {
        if (data == 1) {
            Feng.success("修改成功!");
            window.parent.Reservations.table.refresh();
            CustomerInfoDlg.close();
        } else {
            alert("客户电话已存在");
        }
    }, function (data) {
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
}

CustomerInfoDlg.addRecharge = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var actualAccountBalance = $('#actualAccountBalance').val();
    if (actualAccountBalance != "" && actualAccountBalance == "") {
        alert("请输入充值金额！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/recharge/addRecharge", function (data) {
        Feng.success("添加充值成功!");
        window.parent.Customer.table.refresh();
        CustomerInfoDlg.close();
    }, function (data) {
        Feng.error("添加充值失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
}

/**
 * 重咨提交
 */
CustomerInfoDlg.reconsultingSubmit = function () {
    this.clearData();
    this.collectData();
    if (!this.validate()) {
        return;
    }
    var isReturnVisit = $('#isReturnVisit').val();
    var causeOfNoReturnVisit = $('#causeOfNoReturnVisit').val();
    var refereeShip = $('#refereeShip').val();
    var referee = $('#referee').val();
    if (refereeShip != "" && referee == "") {
        alert("请输入推荐人！");
        return
    }
    if (isReturnVisit == 2 && causeOfNoReturnVisit == "") {
        alert("请输入不回访原因！");
        return
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/customer/reconsulting", function (data) {
        if (data == 1) {
            Feng.success("成功!");
            window.parent.Customer.table.refresh();
            CustomerInfoDlg.close();
        } else {
            alert("客户电话已存在");
        }
    }, function (data) {
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.customerInfoData);
    ajax.start();
}

function onBodyDown(event) {
    if (!(event.target.id == "menuBtn" || event.target.id == "parentCustomerMenu" || $(
            event.target).parents("#parentCustomerMenu").length > 0)) {
        CustomerInfoDlg.hideCustomerSelectTree();
    }
}

//初始化数据
CustomerInfoDlg.initData = function () {
    //状态单选
    var seletecustomerSex = $('#customerSexValue').val();
    if (seletecustomerSex != "") {
        $("#customerSex option[value=" + seletecustomerSex + "]").attr("selected", "selected");
    }
    var seletemaritalStatus = $('#maritalStatusValue').val();
    if (seletemaritalStatus != "") {
        $("#maritalStatus option[value=" + seletemaritalStatus + "]").attr("selected", "selected");
    }
    var seleteisHaveChildren = $('#isHaveChildrenValue').val();
    if (seleteisHaveChildren != "") {
        $("#isHaveChildren option[value=" + seleteisHaveChildren + "]").attr("selected", "selected");
    }
    var seleteisReturnVisit = $('#isReturnVisitValue').val();
    if (seleteisReturnVisit != "") {
        $("#isReturnVisit option[value=" + seleteisReturnVisit + "]").attr("selected", "selected");
    }
    var seletephoneSharShip = $('#phoneSharShipValue').val();
    if (seletephoneSharShip != "" && seletephoneSharShip != "") {
        $("#phoneSharShip option[value=" + seletephoneSharShip + "]").attr("selected", "selected");
    }
}

$(function () {
    Feng.initValidator("customerInfoForm", CustomerInfoDlg.validateFields);
    CustomerInfoDlg.initData();
    //初始化下拉消费习惯列表
    $.post(Feng.ctxPath + "/consumptionHabits/getList", function (data) {
        var txt = '<option value="">--请选择消费习惯--</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].consumption_habits + '">' + data[i].consumption_habits + '</option>';
        }
        document.getElementById('consumptionHabits').innerHTML = txt;
        //状态单选
        var seleteconsumptionHabits = $('#consumptionHabitsValue').val();
        if (seleteconsumptionHabits != "") {
            $("#consumptionHabits option[value=" + seleteconsumptionHabits + "]").attr("selected", "selected");
        }
    }, "json");
    //初始化下拉性格列表
    $.post(Feng.ctxPath + "/character/getList", function (data) {
        var txt = '<option value="">--请选择性格--</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].characters + '">' + data[i].characters + '</option>';
        }
        document.getElementById('characters').innerHTML = txt;
        //状态单选
        var seletecharacters = $('#charactersValue').val();
        if (seletecharacters != "") {
            $("#characters option[value=" + seletecharacters + "]").attr("selected", "selected");
        }
    }, "json");
    //初始化下拉职业列表
    $.post(Feng.ctxPath + "/occupation/getList", function (data) {
        var txt = '<option value="">--请选择职业--</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].occupation + '">' + data[i].occupation + '</option>';
        }
        document.getElementById('occupation').innerHTML = txt;
        //状态单选
        var seleteoccupation = $('#occupationValue').val();
        if (seleteoccupation != "") {
            $("#occupation option[value=" + seleteoccupation + "]").attr("selected", "selected");
        }
    }, "json");
    //初始化下拉消费能力列表
    $.post(Feng.ctxPath + "/consumAbility/getList", function (data) {
        var txt = '<option value="">--请选择消费能力--</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].consum_ability + '">' + data[i].consum_ability + '</option>';
        }
        document.getElementById('consumAbility').innerHTML = txt;
        //状态单选
        var seleteconsumAbility = $('#consumAbilityValue').val();
        if (seleteconsumAbility != "") {
            $("#consumAbility option[value=" + seleteconsumAbility + "]").attr("selected", "selected");
        }
    }, "json");
    //初始化下拉经济能力列表
    $.post(Feng.ctxPath + "/tc/getList", function (data) {
        var txt = '<option value="">--请选择现场TC--</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].tcName + '">' + data[i].tcName + '</option>';
        }
        document.getElementById('fieldTc').innerHTML = txt;
        //状态单选
        var seletefieldTc = $('#fieldTcValue').val();
        if (seletefieldTc != "") {
            $("#fieldTc option[value=" + seletefieldTc + "]").attr("selected", "selected");
        }
    }, "json");
    //初始化下拉经济能力列表
    $.post(Feng.ctxPath + "/refereeShip/getList", function (data) {
        var txt = '<option value="">--请选择与推荐人关系--</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].referee_ship + '">' + data[i].referee_ship + '</option>';
        }
        document.getElementById('refereeShip').innerHTML = txt;
        //状态单选
        var seleterefereeShip = $('#refereeShipValue').val();
        if (seleterefereeShip != "") {
            $("#refereeShip option[value=" + seleterefereeShip + "]").attr("selected", "selected");
        }
    }, "json");

    //初始化下拉预约项目列表
    $.post(Feng.ctxPath + "/payService/getList", function (data) {
        var txt = '<option value="">--请选择预约项目--</option>';
        for (var i = 0; i < data.length; i++) {
            txt += '<option value="' + data[i].department + '">' + data[i].department + '</option>';
        }
        document.getElementById('appointmentPayService').innerHTML = txt;
        //状态单选
        var seletepayservicename = $('#payservicenameValue').val();
        if (seletepayservicename != "") {
            $("#appointmentPayService option[value=" + seletepayservicename + "]").attr("selected", "selected");
        }
    }, "json");
});
